package com.lbn.jfqsc.app.alipay;

import com.lbn.baseframe.mvp.BasePresenter;
import com.lbn.baseframe.net.business.RxSubscribe;
import com.lbn.jfqsc.App;
import com.lbn.jfqsc.net.Host;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 李炳南
 * 2017/3/4.
 */

public class AlipayPresenter extends BasePresenter<IAlipayView> {


    public void alipay(int id,String money,int type){

        Map<String,String>map = new HashMap<>();
        map.put("userId", App.getUser().getId()+"");

//        map.put("", type+"");

        if(type == 1){
            map.put("goodsId", id+"");
            map.put("orderPrice", money);
            subscribeNetwork(Host.getApi().alipay(map), new RxSubscribe<Object>() {
                @Override
                public void next(Object o) {
                    getView().onSucceed();
                }

                @Override
                public void error(Throwable e) {
                    getView().onError(e.getMessage());
                }
            });
        }
        else{
            map.put("actId", id+"");
            map.put("price", money);
            subscribeNetwork(Host.getApi().support(map), new RxSubscribe<Object>() {
                @Override
                public void next(Object o) {
                    getView().onSucceed();
                }

                @Override
                public void error(Throwable e) {
                    getView().onError(e.getMessage());
                }
            });
        }
    }

}
